package com.lv.phuotbacnam.bl;

import java.util.ArrayList;
import java.util.List;

import com.facebook.Request;
import com.facebook.Response;
import com.facebook.model.GraphUser;
import com.lv.phuotbacnam.bl.callback.CallBackFromParse;
import com.parse.ParseFacebookUtils;
import com.parse.ParseUser;

/**
 * Created by Van Quan on 08/09/2014.
 */
@SuppressWarnings("deprecation")
public class Constants {
	/* list friend in facebook who installed app */
	public static List<ParseUser> listUsersInFacebookFriend;

	public static ArrayList<String> ids;

	/**
	 * To get friend list in facebook
	 */

	public static void getFriends(
			final CallBackFromParse<Object, Object> callBackFromParse) {
		Request.executeMyFriendsRequestAsync(ParseFacebookUtils.getSession(),
				new Request.GraphUserListCallback() {

					@Override
					public void onCompleted(List<GraphUser> users,
							Response response) {
						if (users != null) {
							ArrayList<String> id = new ArrayList<String>();
							ids = new ArrayList<String>();
							for (GraphUser user : users) {
								id.add(user.getId());
								ids.add(user.getId());
							}

							// KOUserQueries.getUserFromFbIds(id, new
							// CallBackFromParse<Object, List<ParseUser>>() {
							// @Override
							// public void done(Object request, List<ParseUser>
							// users) {
							// listUsersInFacebookFriend = users;
							// callBackFromParse.done("","");
							// }
							// });
						}
					}
				});
	}

	/**
	 * To check if a String is in List or not
	 * 
	 * @param key
	 * @param ids
	 * @return
	 */
	public static boolean checkInList(String key, ArrayList<String> ids) {
		for (String id : ids)
			if (key.equals(id))
				return true;
		return false;
	}
}
